package com.iwayin.core.dao.comment;

import java.util.List;

import com.iwayin.core.dao.BaseDAOImpl;
import com.iwayin.core.dataobject.CommentDO;

public class CommentDAOImpl extends BaseDAOImpl implements CommentDAO {
	@Override
	public Long addComment(CommentDO commentDO) {
		return (Long) executeInsert("CommentDAO.addComment", commentDO);
	}
	
	@Override
	public void deleteComment(CommentDO  comment) {
		executeUpdate("CommentDAO.deleteComment",comment);
	}
	
	@Override
	public void deleteCommentByAskId(Long askId) {
		executeUpdate("CommentDAO.deleteCommentByAskId", askId);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<CommentDO> findAskComments(CommentDO  query) {
		return this.executeQueryForList("CommentDAO.findAskComments", "CommentDAO.findAskComments.count", query);
	}

	@Override
	public List<CommentDO> findMostCommentToday(Long size) {
		return queryForList("CommentDAO.findMostCommentToday", size);
	}
	@Override
	public CommentDO findLatestComment(Long askId) {
		return (CommentDO) queryForObject("CommentDAO.findLatestComment",askId);
	}

	@Override
	public void commentDittoPlusOne(Long commentId) {
		executeUpdate("CommentDAO.commentDittoPlusOne", commentId);
	}

	@Override
	public void cancelCommentDitto(Long commentId) {
		executeUpdate("CommentDAO.cancelCommentDitto", commentId);
	}
}
